<?php 
/** 
 * 用两个栈来实现一个队列，完成队列的Push和Pop操作。 队列中的元素为int类型。
 */

class MyQueue
{
	private $enter_stack = [];
	private $out_stack = [];

	/**
	 * 入队 
	 */
	public function mypush($data)
	{
       array_push($this->enter_stack, $data);
	}


    /**
     * 出队 
     */
	public function mypop()
	{
		if (empty($this->out_stack)) { // 当出栈为空时，入栈循环push进出栈
			while (!empty($this->enter_stack)) {
    			array_push($this->out_stack, array_pop($this->enter_stack));
    		}
		}
    	return array_pop($this->out_stack);
	}
}

$queue = new MyQueue;
$arr = [1,3,5,6,8,9,7,8,9,5,6,4,5,6];
foreach ($arr as $key => $value) {
	$queue->mypush($value);
}
while ($value = $queue->mypop()) {
	echo $value.PHP_EOL;
}